<?php !defined('BASE_ROOT') && exit ( 'Access Denied!' );
class HttpRequest {

	/**
	 * 设置参数并进行过滤
	 *
	 * @param array $request
	 */
	public function __construct($request) {
		if(get_config('AutoFilter')) {
			$this->filter($request);
			if (!get_magic_quotes_gpc()) {
				$this->filter($_GET);
				$this->filter($_POST);
				//$this->filter($_COOKIE);
				$this->filter($_FILES);
			}
		}
		$_GET = array_merge($request,$_GET);
		$_REQUEST = array_merge($_GET,$_POST);
//		unset($request);
//		unset($HTTP_ENV_VARS);
//		unset($HTTP_POST_VARS);
//		unset($HTTP_GET_VARS);
//		unset($HTTP_POST_FILES);
//		unset($HTTP_COOKIE_VARS);
	}
	/**
	 * 转义
	 *
	 * @param array $array 要过滤的数组
	 * @access protected
	 */
	protected function filter(&$array) {
		if (is_array($array)) {
			foreach ($array as $key => $value) {
				is_array($value) ? $this->filter($value) : $array[$key] = mysql_real_escape_string($value);
			}
		}
	}
}